<?php include("../includes/header-admin.php") ?>
<title>LazySwim</title>
<link rel="stylesheet" href="store.css" type="text/css" />
</head>

<body>
<div id="page">
    <div id="page-top">
        <div id="page-bottom">
          <div id="header">
                <div id="header-info">
                    <h1>LAZYSWIM</h1>
                    <div class="description">Simplistic Swim System</div>
                </div>
				<!-- Header Goes Here -->
                <?php printHeader(); ?>
				<!-- Header Ends Here -->
                <div id="header-date">Today is <?php echo date('l, F jS, Y'); ?></div>
                <div id="header-cats">
				<!-- Welcome Message Starts Here -->
                    <ul>
					<?php include("../../includes/welcomeBar.php"); ?>
					</ul>
				<!-- Welcome Message Ends Here -->	
                </div>
            </div>
            <div id="main">
                <div id="sidebar">                 
                    <?php
					// include the corresponding navigation pages
                    include("../../includes/navigation.php");
					?>     
                </div>                     

            <!-- main body -->
			<div class="featured-post"> 
			
				<div class="post-title"><h2> Import/Export CSV File</h2></div>
				<div class="post-entry">   
		
				<?php
                    require("csvFunctions.php");
                    if( $_POST['import'] && isset($_FILES['uploadedfile'])  ){
                        $csvfile = $_FILES['uploadedfile']['tmp_name'];
                        
                        $file = fopen($csvfile,"r");
                        if(!$file) {
                            die ("Error opening data file $csvfile.<br>");
                        }
                        $size = filesize($csvfile);
                        
                        if(!$size) {
                            die ("File is empty.<br>");
                        }

                        $csvcontent = fread($file,$size);
                        fclose($file);
                        processLines($csvcontent);
					}
				?>
                
                <form enctype="multipart/form-data" action="importFile.php" method="POST">
                    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
                    Choose a file to import: <input type="file" name="uploadedfile" /><br />
                    <input type="submit" value="Import" name="import"/>
                </form>
				<br><br>	
                
                 <form name="exportForm" action="csvFunctions.php" method="POST">
                    <input type="submit" value="Export Data" name="export"/>
                </form>
				<br><br>	
                    
				<!-- end of main -->
				</div>
			</div>	
				
            <div class="clear"></div>

            </div>
			<!-- Footer Goes Here -->
            <?php include("../../includes/footer.php"); ?>
			<!-- Footer Ends Here -->
        </div>
    </div>
</div>
</body>
</html>